
dict1={
    "G1569":("北京南","天津南","11月08日","18:06","18:39","00:33"),
    "G1567":("北京南","天津南","11月08日","18:15","18:49","00:34"),
    "G8917":("北京南","天津南","11月08日","18:20","19:19","00:59"),
    "G203":("北京南","天津南","11月08日","18:35","19:09","00:33")
}
print("车次\t\t出发站\t到达站\t出发日期\t出发时间\t到达日期\t历时时长")  #
for a,b in dict1.items():  #对字典进行遍历
    print(a,end="\t")  #打印key
    for c in b:   #对value进行遍历
        print(c,end="\t")
    print()
checi=input("请输入要购买的车次").upper()   #upper() 把小写字母变成大写字母
if checi in dict1.keys():
    peo_list=[]  #乘车人列表
    che_info = dict1[checi]  # 获取到车辆的信息，如果我们的key是变量，获取值不不需要添加引号
    while True:
        people=input('请输入乘车人：').upper()
        if people=="否" or people=="N":  #判断输入的是否是 否，还是N,如果不是就继续输入人名，否则跳出循环
            break
        else:
            peo_list.append(people) #把乘车人追加到列表内
    for p in peo_list:
         print(f"【12306】{p}购票成功，{che_info[2]}{checi}次，{che_info[0]}{che_info[3]}开")
    #需要多次打印
else:
    print("车次不存在")







